export function getCategoryNameById(categoryId,categoryList) {
  for(let i = 0; i < categoryList.length; i++){
    if(categoryList[i].categoryId == categoryId){ return categoryList[i].text}
  }
  return "";
}

export function getCategoryById(categoryId,categoryList) {
  for(let i = 0; i < categoryList.length; i++){
    if(categoryList[i].categoryId == categoryId){ return categoryList[i]}
  }
  return null;
}

export function getParentById(categoryId,categoryList) {
  var res = [];
  var category = getCategoryById(categoryId,categoryList);
  if(category == null) return [];
  while(category.categoryId !== 0){
    res.push({categoryId:category.categoryId,categoryName:category.text});
    if(category.parentId === 0) break;
    category = getCategoryById(category.parentId,categoryList);
  }
  return res.reverse();
}
